<?php
/**
 * @filesource:				    SteleMakeRequestAction.class.php
 * @desc:						墓地管理模块
 * 
 * @author:						shenyaqing
 * @copyright:					hou.yining@gmail.com
 * @date:						2011-05-16
 */
class SteleMakeRequestAction extends CommonAction{
	public function index(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('stele_make_manage'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/add', 'title' => L('add_stele_make')),
		);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		parent::index();
	}
	public function add(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('stele_make_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/add', 'title' => L('add_stele_make'), 'sort' => C('CRUMB_LAST')),
		);
		
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_stele_make')),
			);
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
	   //生成单据编号
		$stelemake = new SteleMakeRequestModel();
		$info = $stelemake->order('id desc')->limit(1,1)->find();
		$request_id = 'BWZZ'.date('Ymd',time()).substr('10000000'+$info[id]+1,1);
		$this->assign('request_id',$request_id);
		$this->display();
	}
	public function edit(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('stele_make_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/edit/id/' . $_REQUEST['id'], 'title' => L('edit_stele_make'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_stele_make')),
			);
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
//		$graveyard_repair = new GraveyardRepairRequestModel();
//		$id = $_REQUEST [$graveyard_repair->getPk ()];
//		$vo = $graveyard_repair->where("id='$id'")->select();
//		$this->assign('list',$vo);
		parent::edit();
	}
	public function search(){
		if(!empty($_POST['request_id'])){
			$where['request_id'] = $_POST['request_id'];
		}
		if(!empty($_POST['dead'])){
			$where['dead_id'] = $_POST['dead'];
		}
		if(!empty($_POST['graveyard_id'])){
			$where['graveyard_id'] = $_POST['graveyard_id'];
		}
		if(!empty($_POST['creater_name'])){
			$where['creater_name'] = $_POST['creater_name'];
		}
		if(!empty($_POST['charge_person_id'])){
			$where['charge_person_id'] = $_POST['charge_person_id'];
		}
		$graveyard_repair = new GraveyardRepairRequestModel();
		$a = $graveyard_repair->where($where)->select();
		$this->assign('list',$a);
		$this->display('index');
		
	}
	public function view(){
		$name=$this->getActionName();
		$model = M ( $name );
		$id = $_REQUEST [$model->getPk ()];
		$info = new SteleMakeRequestModel();
		$list = $info->getInfo($id);
		dump($list);
		$this->assign('list',$list);
		$this->display();
	}
	
}
?>
